package com.majorty.mb.service.impl;

import com.majorty.mb.controller.request.UserRequest;
import com.majorty.mb.controller.response.PageTemplateUtil;
import com.majorty.mb.controller.response.PaginationResult;
import com.majorty.mb.dao.UserDao;
import com.majorty.mb.dao.entity.UserDO;
import com.majorty.mb.service.UserService;

import org.springframework.stereotype.Service;

import java.util.List;

import javax.annotation.Resource;

/**
 * @author zhangshuai
 * @date 2019-09-21 23:10
 */
@Service("userServiceImpl")
public class UserServiceImpl implements UserService {

    @Resource(name = "userDao")
    private UserDao userDao;

    @Override
    public PaginationResult<UserDO> getUserList(UserRequest request) {
        Integer total = userDao.getUserListCount();
        PaginationResult<UserDO> paginationResult = new PaginationResult<>();
        PageTemplateUtil.setPagination(request,paginationResult,total);
        List<UserDO> userList = userDao.getUserList(request);
        paginationResult.setList(userList);
        return paginationResult;
    }

    @Override
    public UserDO selectById(Integer id) {
        return userDao.selectById(id);
    }


}
